<?php
require_once(FWS_DIR_LIB.'core/ModelAndView.class.php');
require_once(FWS_DIR_MODEL_DAO.'flashmodeldao.class.php');
require_once(FWS_DIR_MODEL.'flashmodel.class.php');
require_once(FWS_DIR_MODEL_DAO.'eventmodeldao.class.php');
require_once(FWS_DIR_MODEL.'eventmodel.class.php');

class flashMultiActionController {

	var $_flashmodeldao;
	var $_eventmodeldao;
	
	function flashMultiActionController() {
		$this->_flashmodeldao = new FlashModelDao();
		$this->_eventmodeldao = new EventModelDao();
		mysql_connect(FWS_DBDOMAIN,FWS_DBUSER,FWS_DBPASS) or exit(mysql_error());
		mysql_select_db(FWS_DBNAME) or exit(mysql_error());
	}
	
	function adminlist_action() {
		$mv = new ModelAndView();
		$mv->addToModel(0, $this->_flashmodeldao->findAllFlashForAdmin());
		$mv->setView('adminflash_list.tpl');
		mysql_close();
		return $mv;
	}
	
	function form_action() {
		$mv = new ModelAndView();
		if(is_numeric(get("id"))) $mv->addToModel(1,$this->_flashmodeldao->selectFlash(get("id")));
		$mv->setView('flash_form.tpl');
		mysql_close();
		return $mv;
	}
	
	function update_action() {
		$mv = new ModelAndView();
		$this->_flashmodeldao->updateFlash(new FlashModel($_POST));
		return $this->adminlist_action();
	}
	
	function insert_action() {
		$mv = new ModelAndView();
		$this->_flashmodeldao->insertFlash(new FlashModel($_POST));
		return $this->adminlist_action();
	}

	function delete_action() {
		$mv = new ModelAndView();
		$this->_flashmodeldao->deleteFlash(get("id"));
		return $this->adminlist_action();
	}

	
	function listflashinfo_action() {
		$flash = $this->_flashmodeldao->findAllFlashinfo();
		mysql_close();
		return $flash;
	}
	
}

?>